package com.yoosora.utils;

import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

@Component
public class FileUtils {
	public static Boolean isExists(String fileString){
		File file = new File(fileString);
		if(file.exists()){
			return true;
		}else{
			return false;
		}
	}
	public static String readJsonString(String file){
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file),StandardCharsets.UTF_8));
			StringBuilder sb = new StringBuilder();
			String temp;
			while ((temp = br.readLine())!=null){
				sb.append(temp);
			}
			br.close();
			return sb.toString();
		} catch (IOException e) {
			return null;
		}
	}
}
